/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.dtgenerator.api;

import com.inspur.edp.bef.dtgenerator.BEGeneratorContext;
import com.inspur.edp.bef.dtgenerator.api.entityInterface.BEEntityInterfaceGenerator;
import com.inspur.edp.bef.dtgenerator.api.entityInterface.BEEntitySingleInterfaceGenerator;
import com.inspur.edp.bef.dtgenerator.api.entityInterface.BeEntityAllInterfaceGenerator;
import com.inspur.edp.bef.dtgenerator.api.mgrInterface.BEMgrAllInterfaceGenerator;
import com.inspur.edp.bef.dtgenerator.api.mgrInterface.BEMgrInterfaceGenerator;
import com.inspur.edp.bef.dtgenerator.api.mgrInterface.BEMgrSingleInterfaceGenerator;
import com.inspur.edp.bef.dtgenerator.api.mgrInterface.resourceInfo.BefModelInfoGenerator;
import com.inspur.edp.cef.generator.apiGenerator.commonModel.CommonModelApiGenerator;
import com.inspur.edp.cef.generator.apiGenerator.commonModel.CommonModelApiGeneratorContext;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrAllInterface.MgrAllInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.MgrInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.MgrSingleInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.mgrInfo.MgrInfoBaseGenerator;
import com.inspur.edp.cef.generator.apiGenerator.dataType.mgrInterface.resourceInfo.ModelInfoBaseGenerator;
import com.inspur.edp.cef.generator.apiGenerator.entity.allInterface.EntityAllInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.entity.separateInterface.EntityInterfaceGenerator;
import com.inspur.edp.cef.generator.apiGenerator.entity.separateInterface.EntitySingleInterfaceGenerator;

public class BefApiGenerator extends CommonModelApiGenerator {
  public BefApiGenerator(BEGeneratorContext beGenCtx) {
    super(beGenCtx, beGenCtx.getBE(), beGenCtx.getParentBE());
  }

  private BEGeneratorContext getBeGenCtx() {
    return (BEGeneratorContext)
        ((super.cmGenCtx instanceof BEGeneratorContext) ? super.cmGenCtx : null);
  }

// keyword:
  // ORIGINAL LINE: private new  befApiGeneratorContextgetContext() { return
  // (BefApiGeneratorContext)super.getContext(); }
  @Override
  public BefApiGeneratorContext getContext() {
    return (BefApiGeneratorContext) super.getContext();
  }

  @Override
  protected CommonModelApiGeneratorContext createCMApiGenCtx() {
    return new BefApiGeneratorContext(getBeGenCtx());
  }

//  @Override
//  protected java.util.ArrayList<BaseGenerator> getExtendCMGenerators() {
//    java.util.ArrayList<BaseGenerator> list = super.getExtendCMGenerators();
//    if (list == null) {
//      list = new java.util.ArrayList<BaseGenerator>();
//    }
////    list.add(new MgrAssFactoryInterfaceGenerator(getContext()));
////    list.add(
////        new BEAssFactoryInterfaceGenerator(
////            getContext(), getContext().getBeGenCtx().getBE().getMainObject(), true));
//    return list;
//  }

  @Override
  protected EntityAllInterfaceGenerator getEntityAllInterfaceGenerator() {
    return new BeEntityAllInterfaceGenerator(getContext(), getBeGenCtx().getBE().getMainObject());
  }

  @Override
  protected EntityInterfaceGenerator getEntityInterfaceGenerator() {
    return new BEEntityInterfaceGenerator(getContext(), getBeGenCtx().getBE().getMainObject());
  }

  @Override
  protected EntitySingleInterfaceGenerator getEntitySingleInterfaceGenerator() {
    return new BEEntitySingleInterfaceGenerator(getContext(), getBeGenCtx().getBE().getMainObject());
  }

  @Override
  protected MgrSingleInterfaceGenerator getSingleMgrInterfaceGenerator() {
    return new BEMgrSingleInterfaceGenerator(getContext());
  }

  @Override
  protected MgrAllInterfaceGenerator getMgrAllInterfaceGenerator() {
    return new BEMgrAllInterfaceGenerator(getContext());
  }

  @Override
  protected MgrInterfaceGenerator getMgrInterfaceGenerator() {
    return new BEMgrInterfaceGenerator(getContext());
  }

  @Override
  protected ModelInfoBaseGenerator createModelInfoGenerator() {
    return new BefModelInfoGenerator(getContext(), getContext().getBeGenCtx().getBE());
  }

  @Override
  protected MgrInfoBaseGenerator createMgrInfoGenerator() {
    return null;
  }

  @Override
  protected boolean getIsSingleInterface() {
    return getContext().getCommonModel().isSimplifyGen();
  }

  //  @Override
//  protected void afterGenerate() {
//    super.afterGenerate();
//    // todo:wj
//    // BeGenCtx.MgrAssFactoryInterfaceType =
//    // getContext().Assembly.GetType(getContext().MgrActionAssFactoryInterfaceType.FullName);
//    // SetEntityAssFactoryInterfaces();
//  }

//  private void setEntityAssFactoryInterfaces() {
//    // todo:wj
////    for (var item : getContext().getBEActionAssFactoryInterfaceTypes()) {
//    // BeGenCtx.EntityAssemblerFactoryInterfaceTypes.Add(item.Key
//    //	, item.Value);
//    // getContext().Assembly.GetType(item.Value.FullName));
//    //    }
//  }
}
